SET(TUI_BASE
	${CMAKE_CURRENT_SOURCE_DIR}/../../../shmif/tui)

SET(SOURCES
	${CMAKE_CURRENT_SOURCE_DIR}/arcterm.c
	${CMAKE_CURRENT_SOURCE_DIR}/cli.c
	${CMAKE_CURRENT_SOURCE_DIR}/cli_parse.c
	${CMAKE_CURRENT_SOURCE_DIR}/cli_builtin.c
	${CMAKE_CURRENT_SOURCE_DIR}/cli_lua.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/tsm_vte.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/tsm_vte_charsets.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/shl-pty.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/shl-ring.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/tsm_screen.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/tui_deprecated.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/tsm_unicode.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/shl_htable.c
	${CMAKE_CURRENT_SOURCE_DIR}/tsm/wcwidth.c
	${TUI_BASE}/lua/tui_lua.c
	${TUI_BASE}/lua/tui_lua_glob.c
	${TUI_BASE}/lua/nbio.c
	${TUI_BASE}/lua/tui_popen.c
)

set(DEFS)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
else()
	LIST(APPEND SOURCES
		${CMAKE_CURRENT_SOURCE_DIR}/st/st.c
		${CMAKE_CURRENT_SOURCE_DIR}/st/tui.c
	)
LIST(APPEND DEFS SALLOW_ST)
endif()

if (NOT LUA_LIBRARY)
	find_package(Lua51 REQUIRED)
endif()

if (FSRV_TERMINAL_NOEXEC)
	LIST(APPEND DEFS FSRV_TERMINAL_NOEXEC)
endif()

SET(TERMINAL_DEFS ${DEFS} PARENT_SCOPE)
SET(TERMINAL_SOURCES ${SOURCES} PARENT_SCOPE)

SET(TERMINAL_LIBS
	util
	arcan_tui
	${LUA_LIBRARIES}
	PARENT_SCOPE
)

set(TERMINAL_INCLUDE_DIRS
	${CMAKE_CURRENT_SOURCE_DIR}/tsm
	${LUA_INCLUDE_DIR}
	${TUI_BASE}/lua
	PARENT_SCOPE
)
